package com.qwen.controller;

import com.qwen.service.TongyiService;
import org.springframework.ai.image.ImageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: springboot3-demos
 * @description:
 * @author: Reagan Li
 * @create: 2024-07-03 16:00
 **/

@RestController
@RequestMapping("/tongyi")
public class TongyiController {

    @Autowired
    private TongyiService tongyiService;

    @GetMapping("/chat")
    public ResponseEntity chat(@RequestParam("msg") String msg) {
        String chat = tongyiService.chat(msg);
        return ResponseEntity.ok(chat);
    }

    @GetMapping("/image")
    public ResponseEntity image(@RequestParam("msg") String msg) {
        ImageResponse imageResponse = tongyiService.genImg(msg);
        return ResponseEntity.ok(imageResponse);
    }

    @GetMapping("/audio")
    public ResponseEntity audio(@RequestParam("msg") String msg) {
        String s = tongyiService.genAudio(msg);
        return ResponseEntity.ok(s);
    }
}
